package unit02;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author wangzhuangzhuang
 * @DESC:
 * @date 2022-05-08 22:54
 */
public class FunctionDemo {
	public static void main(String[] args) {
		ArrayList<String> names = new ArrayList<>(Arrays.asList("Test01", "Test02", "Test03"));
		List<Integer> namesLengths = names.stream()
				.map(new Function<String, Integer>() {
					@Override
					public Integer apply(String s) {
						return s.length();
					}
				})
				.collect(Collectors.toList());

		namesLengths = names.stream()
				.map(s -> s.length())
				.collect(Collectors.toList());

		namesLengths = names.stream()
				.map(String::length)
				.collect(Collectors.toList());

	}
}